function Get-ScriptDirectory
{
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value
    Split-Path $Invocation.MyCommand.Path
}

$pathRoot = Resolve-Path (Join-Path (Get-ScriptDirectory) "..")
$pathSource = Resolve-Path (Join-Path (Get-ScriptDirectory) "..\Source")
$pathThirdParty = Resolve-Path (Join-Path (Get-ScriptDirectory) "..\Source\ThirdPartyLibraries")
$pathDistribution = Join-Path $pathRoot Distribution

$pathSharpZip = "$pathThirdParty\ICSharpCode.SharpZipLib.dll";

[System.Reflection.Assembly]::LoadFrom($pathSharpZip) > $null

function Zip($zipFile, $leadingFolderPathToRemove)
{
  begin
  {
    $zip = [ICSharpCode.SharpZipLib.Zip.ZipFile]::Create($zipFile)
    $zip.BeginUpdate()
  
    #add trailing backslash if necessary
    $leadingFolderPathToRemove = (Join-Path $leadingFolderPathToRemove '\')
  }
  process
  {
    #remove leading folder path from file name
    $file = $_.FullName.Remove(0, $leadingFolderPathToRemove.Length)
    $zip.Add($_.FullName, $file)
  }
  end
  {
    $zip.CommitUpdate()
    '{0} files zipped' -f $zip.Count
    $zip.Close()
  }
}

function Unzip($zipFile, $unzipToFolder)
{
  $zip = New-Object ICSharpCode.SharpZipLib.Zip.FastZip
  $zip.ExtractZip($zipFile, $unzipToFolder, $null)
}

function Load-Settings($settingsFile)
{
	$configKeys = @{}
	Get-Content $settingsFile | ForEach-Object {
		$keys = $_ -split "="
		$configKeys += @{ $keys[0]=$keys[1] }
	}
	$configKeys
}